package com.erhirent.view;

import java.util.List;

import com.erhairent.tools.InputTools;
import com.erhirent.bean.Car;
import com.erhirent.biz.ICarBiz;
import com.erhirent.biz.IUserBiz;
import com.erhirent.bizimpl.CarBizImpl;
import com.erhirent.bizimpl.UsersBizImpl;

public class RecordView extends View {
	ICarBiz mcar = new CarBizImpl();
	IUserBiz muser = new UsersBizImpl();

	@Override
	public View showView() {
		String name = null;
		boolean isContinue = true;
		for (; isContinue;) {
			System.out.println("输入您的账号:");
			name = InputTools.next();
			System.out.println("请输入密码 :");
			String Pwd = InputTools.next();
			// 判断用户是否存在
			if (muser.isSame(name, Pwd)) {
				System.out.println(name);
				System.out.println("这是你的账户名?1.是  2.否");
				int c = InputTools.nextInt();
				if (c == 1) {
					isContinue = false;
				} else {
					System.out.println("重新输入:");
				}
			} else {
				System.out.println("密码错误");
			}
		}
		int id = muser.GetUserId(name);
		List<Car> list = mcar.userqueryRecord(id);
		if (list.size() != 0) {
			System.out.println("------------------------------------");
			System.out.println("汽车编号\t" + "汽车名称\t" + "总价\t" + "备注\t" + "品牌\t" + "类型\t" + "租车时间\t\t\t\t" + "还车时间");
			for (Car car : list) {
				System.out.print(car.getcarId() + "\t");
				System.out.print(car.getcarName() + "\t");
				System.out.print(car.getrentTotalPrice() + "\t");
				System.out.print(car.getcarRemark() + "\t");
				System.out.print(car.getbrandName() + "\t");
				System.out.print(car.gettypeName() + "\t");
				System.out.print(car.getrentTime() + "\t");
				System.out.println(car.getreturnTime() + "\t");
			}
			System.out.println("------------------------------------");
		} else {
			System.out.println("查询失败");
			return mView;
		}

		return mView;
	}

}
